package com.FH.applyFrom.advanceForm;

import com.FH.organization.work_flow.WorkFlowPullDTO;
import com.FH.util.ResultDTO;

import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

/**
 * Created by Administrator on 2016/7/15.
 * 预支费用申请单资源类
 */

@Path("/advanceForm")
@Produces(MediaType.APPLICATION_JSON)
@RequestScoped
public class AdvanceFormResource {

    @EJB
    private AdvanceFormDAO advanceFormDAO;

    @GET
    @Path("/{search}&{page}&{size}")
    public ResultDTO getVacationFormInfo(@PathParam("search") String search, @PathParam("page") String page, @PathParam("size") String size){
        //添加分页查询
        if(null==page||"".equals(page)||"0".equals(page))
        {
            page = "1";	//默认从第1页开始查起
        }
        if(null==size||"".equals(size))
        {
            size = "10";//默认10行数据
        }
        return advanceFormDAO.getAdvanceFormInfo(search,page,size);
    }

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO addVacationFormInfo(AdvanceFormPullDTO advanceFormPullDTO){
        return advanceFormDAO.addAdvanceFormInfo(advanceFormPullDTO);
    }

    /**
     * 删除
     * @param advanceFormPullDTO
     * @return
     */
    @PUT
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO deleteVacationFormInfo(AdvanceFormPullDTO advanceFormPullDTO){
          return advanceFormDAO.deleteAdvanceFormInfo(advanceFormPullDTO);
    }


    /**
     * 修改
     * @param dataDTO
     * @return
     */
    @PUT
    @Path("/update")
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO updateAdvanceFormInfo(AdvanceFormPullDTO dataDTO){

        return advanceFormDAO.updateAdvanceFormInfo(dataDTO);

    }


}
